Colors in statistical graphics

Mahbubul Majumder, PhD
Feb 14, 2017

What is color?

  • color
    • property possessed by an object of producing different sensations on the eye as a result of the way the object reflects or emits light
    • may be difference between what we see and what we perceive
  • there are three cones that help perceiving different segment of light

    • L for long web lenth
    • M for medium web length
    • S for small web length
  • in statistical graphics colors are mapped to some variables

    • continuous color
    • discrete color

How do we see color?

  • Human eye has

    • five million cone cells
    • 20 times more rod cells
  • Cone captures color

  • Rod captures brightness

  • Brain processes them and we finally perceive

color-eye

Picture Source: http://jfly.iam.u-tokyo.ac.jp/color/

RGB color space

  • what is RGB color?
    • each color is combination of three primary colors: red, green and blue
    • if any two of them are missing, it produces pure third color
    • TV and computer screens are equipped with three colors
cols <- rgb(r=c(1,0,0), g=c(0,1,0), b=c(0,0,1))
df <- data.frame(x=1:3, y=1)
ggplot(df, aes(x,y)) + geom_bar(fill=cols, stat="identity")

plot of chunk unnamed-chunk-2

Color palette selection

color-selection

R Color palettes

  • For discrete data
    • brewer
    • grey
  • For continuous data
    • gradient2
    • gradientn

Reading assignment and references

Window size: x
Viewport size: x